﻿//-----------------------------------------------------------------------
// <copyright>
//     Copyright (c) Artur Mustafin. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using Excel.Expressions.Compiler;
using Expressions.Compiler;

namespace Excel.Expressions
{
    public static class Text
    {
        public static CellExpression Parse(string text)
        {
            Parser<char> parser = text.ToCharArray();
            Nonterminal<char> nonterminal = Nonterminals.cell_expression;
            Expression<char, CellExpression> expression = Expressions.cell_expression;

            nonterminal.Initialize();
            nonterminal.Validate();

            if (nonterminal.Parse(parser))
            {
                return expression[parser.Tree];
            }
            return null;
        }
    }
}
